import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';
import 'package:yysk_app/widget/custom_app_bar2.dart';
import 'package:yysk_app/widget/lazy_network_image.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

class ShowImagePage extends StatefulWidget {
  const ShowImagePage({super.key});
  static const path = '/ShowImagePage';

  @override
  State<ShowImagePage> createState() => _ShowImagePage();
}

class _ShowImagePage extends State<ShowImagePage> {
  late String url;
  InAppWebViewController? webViewController;
  late String _titleName = '元宇时空';
  late String _url = '';
  @override
  void initState() {
    super.initState();
    final params = Get.parameters;
    final args = Get.arguments ?? {};
    var rawUrl = params['url'] ?? args['url'];
    url = Uri.decodeComponent(rawUrl);
    _titleName =  params['title']??args['title'] ?? '元宇时空';
    _url = url;
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(child:  Scaffold(
      appBar: 
      CustomAppBar2(
                title: _titleName,
                context: context,
                textColors: AppColors.fontColor,
              ),
      
      body: SingleChildScrollView(
        child: SizedBox(
          width: 375.px,
          height: context.height,
          child: Stack(children: [_background()]),
        ),
      ),
    ));
  }

  _background() {
    return Positioned.fill(
      top: 0.px,
      left: 0,
      child: SingleChildScrollView(
        child: LazyImage(
        imageUrl: _url,
        width: 375.px,
        // height: 354.px,
        borderRadius: 0,
        aotuHeight: true,
        boxFit: BoxFit.fitWidth,
        alignment: Alignment.topCenter,
      ),
      ),
    );
  }
}
